package com.cat.math;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/closest-divisors/
 * @create 2025/10/16 20:35
 * @since JDK17
 */

public class Solution16 {
    int diff = Integer.MAX_VALUE;
    int[] ans = new int[2];
    void f(int num) {
        for (int i = 1; i * i <= num; i++) {
            if (num % i == 0) {
                int j = num / i;
                if (Math.abs(j - i) < diff) {
                    ans = new int[]{i, j};
                    diff = Math.abs(i - j);
                }
            }
        }
    }
    public int[] closestDivisors(int num) {
        f(num + 1);
        f(num + 2);
        return ans;
    }
}
